#version 150


//Vertex
in vec3 position;
in vec2 uv;
in vec3 norm;

//Marerial
uniform vec4 diffColor;
uniform vec3 reflexion;
uniform float shininess;
uniform float refraction;

//Ambiant
uniform vec4 aColor;

//Positional
uniform vec4 lightpos;
uniform vec4 lightcolor;

//Transformation
uniform mat4 mvp;
uniform mat4 model;

out vec4 fColor0;
out vec4 normal;
out vec4 lightVector;
out vec4 lightColor;
out vec2 texCoord;
out vec4 ambiant;

void main(void)
{
  //Position
  gl_Position = mvp * vec4(position, 1.0f);
  
  //Matrice des normales
  mat4 trsp = transpose(inverse(model));  
  
  ambiant = aColor;
  
  //Du point à la lampe
  vec4 objPos = normalize(trsp*vec4(position, 1.0f));
  normal = normalize(trsp*vec4(norm, 0.0f));
  
  lightVector = normalize(lightpos-objPos);
  lightColor = lightcolor;
  
  fColor0 = diffColor;
  texCoord = uv;
}
